package com.xrkj.miniprogram.server.controller;

import com.xrkj.miniprogram.server.service.LoginService;
import core.Data;
import core.data.DataResult;
import net.glxn.qrgen.core.image.ImageType;
import net.glxn.qrgen.javase.QRCode;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Base64Utils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;

@RestController
public class LoginController {
    @Autowired
    LoginService service;

    //用户请求登录
    @PostMapping("/login")
    public DataResult login(String wxid) {
        return Data.create(wxid).addHandle("params",data -> {
            String result=service.login(data.getParams());//执行登录操作，如果登陆成功就返回true，否则返回false

            if(result.equals("login_failed")){
                data.failure("登陆失败");
            }else {
                data.success(result);
            }
        }).start().getResult();

    }



}
